﻿@model IndignadoFramework.FrontOffice.Models.ContenidoUploadModel

<script type="text/javascript">
    function validate() {
        var combo = document.getElementById('Tipo');
        var url = document.getElementById('URL');
        var fileChooser = document.getElementById('ContenidoUpload_Archivo');
        var submitButton = document.getElementById('submit_button');

		if (combo.value == 'Link') {
			if (url.value != '') {
				document.forms['cont_form'].submit();
			}
		}
		else {
			if (fileChooser.value != '') {
				document.forms['cont_form'].submit();
			}
		}
	}

	function clickOption(opt) {
	    var link = document.getElementById('link_button');
	    var video = document.getElementById('video_button');
	    var image = document.getElementById('image_button');
	    var coment = document.getElementById('Comentario');
	    var file = document.getElementById('Archivo');
        var combo = document.getElementById('Tipo');
	    var url = document.getElementById('URL');
	    var fileChooser = document.getElementById('ContenidoUpload_Archivo');
	    var submitButton = document.getElementById('submit_button');

		if (opt == 'Link') {
			coment.style.display = '';
			url.style.display = '';
			file.style.display = 'none';
			link.innerHTML = '<b>Link</b>';
			video.innerHTML = 'Video';
			image.innerHTML = 'Imagen';
		}
		else {
			coment.style.display = 'none';
			url.style.display = 'none';
			file.style.display = '';
			if (opt == 'Video') {
				link.innerHTML = 'Link';
				video.innerHTML = '<b>Video</b>';
				image.innerHTML = 'Imagen';
				fileChooser.accept = 'video/*';
			}
			else {
				link.innerHTML = 'Link';
				video.innerHTML = 'Video';
				image.innerHTML = '<b>Imagen</b>';
				fileChooser.accept = 'image/*';
			}
		}
		combo.value = opt;
		submitButton.style.display = '';
	}
</script>

<link rel="stylesheet" type="text/css" href="@Url.Content("~/Content/Contenido.css")" />

@using (Html.BeginForm("Agregar", "Contenido", FormMethod.Post, new { id="cont_form", enctype = "multipart/form-data" }))
{
	<p id="title">Elija el tipo de contenido a subir</p>
	<p></p>
	<div id="video_button" onclick="clickOption('Video')">Video</div>
	<div id="image_button" onclick="clickOption('Imagen')">Imagen</div>
	<div id="link_button" onclick="clickOption('Link')">Link</div>
	<p></p>
	<div id="Comentario" style="display: none">
		<div class="editor-label">
			@Html.LabelFor(m => m.Comentario)
		</div>
		<div class="editor-field">
			@Html.TextBoxFor(m => m.Comentario, new { size = 55, style = "padding: 4px" })
		</div>
	</div>
	
	<div id="URL" style="display: none">
		<div class="editor-label">
			@Html.LabelFor(m => m.URL)
		</div>
		<div class="editor-field">
			@Html.TextBoxFor(m => m.URL, new { size = 55, style = "padding: 4px" })
		</div>
	</div>
	
	<div id="Archivo" style="display: none">
		<div class="editor-label">
			@Html.LabelFor(m => m.Archivo)
		</div>
		<div class="editor-field">
			<input type="file" name="ContenidoUploadArchivo" id="ContenidoUpload_Archivo" />
		</div>
	</div>

	<div class="editor-field" style="display: none">
		@Html.DropDownListFor(m => m.Tipo, new SelectList(Enum.GetValues(typeof(IndignadoFramework.FrontOffice.Models.ContenidoUploadModel.TipoArchivo))))
	</div>		
	<p id="submit_button" style="display: none">
		<input type="button" value="Publicar" onclick="validate()" />
	</p>
}